package com.filter;

import com.entity.Poker;
import com.mike.median.util.PokerUtil;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * 重复牌面过滤
 * number 重复次数
 */
public class NumberOfKindGroupFilter extends BaseGroupFilter {
    private int number;

    public NumberOfKindGroupFilter(List<Poker> pokers, int number) {
        super(pokers);
        this.number = number;
    }

    @Override
    protected boolean filterHandler() {
        Map<Integer, Integer> resultMap = PokerUtil.groupNum(pokers);
        Iterator<Integer> numSet = resultMap.keySet().iterator();
        while (numSet.hasNext()) {
            if (resultMap.get(numSet.next()) == number) {
                return true;
            }
        }
        return false;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}
